﻿// --------------------------------
// <copyright file="IMembershipRepository.cs" company="Pattern Web Solutions">
//     Copyright © Simon Gill 2010. Distributed under the GPL.
// </copyright>
// <author>Simon Gill</author>
// ---------------------------------
// This file is part of League Manager

// League Manager is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.

// League Manager is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with League Manager.  If not, see <http://www.gnu.org/licenses/>.

namespace LeagueManager.Models
{
    using System;
    using System.Collections.Generic;
    using System.Linq;

    /// <summary>
    /// Interface for the provider of read and write access to all data needed by the program.
    /// </summary>
    public interface IMembershipRepository
    {
        /// <summary>
        /// Gets all active games.
        /// </summary>
        /// <returns>All Game objects with a status of Active.</returns>
        IQueryable<Game> AllActiveGames();

        /// <summary>
        /// Gets all games.
        /// </summary>
        /// <returns>All Game objects.</returns>
        IQueryable<Game> AllGames();

        /// <summary>
        /// Add a new game to the list of games.
        /// </summary>
        /// <param name="game">The details of the new game to add.</param>
        void AddGame(Game game);
        
        /// <summary>
        /// Get all the match results.
        /// </summary>
        /// <returns>All match results in a ready-to-display format.</returns>
        IQueryable<DisplayResult> AllGameResults();

        IQueryable<MemberRanking> AllPlayersByOverallRanking(DateTime start, DateTime end);
        
        IQueryable<MemberRanking> AllPlayersByOverallRanking();
        
        IList<GameRanking> AllPlayersRankedByActiveGame();
        
        IList<GameRanking> AllPlayersRankedByActiveGame(DateTime start, DateTime end);
        
        IList<LeagueRanking> AllPlayersRankedByLeaguePoints(int year, int month);
        
        IEnumerable<LeagueProStanding> AllPlayersRankedByProPoints(int year);
        
        IQueryable<Member> AllMembers();
        
        int GetLeagueValue(string valueName, DateTime date);
        
        void SaveChanges();
        
        void SeedLevels();
        
        void SeedLevels(int playersPerLevel, int numberOfLevels);
        
        void SetLevelBasedOnPreviousMonth(int year, int month);
        
        void UpdateStandingsForMonth(int year, int month);
        
        void UpdateStandingsForYear(int year);
        
        void AddResult(GameResult newResult);
        
        void RemoveGameResults(IList<long> gameIDs);

        void SaveMember(Member member);

        object GameResultsForMember(Member member);

        void SetFavoriteGamesFor(Member member, IEnumerable<Game> games);

        /// <summary>
        /// Issue a chosen membership number to the member.
        /// </summary>
        /// <param name="member">The member to issue the new number to.</param>
        /// <param name="number">The new membership number to assign.</param>
        /// <exception cref="InvalidOperationException">InvalidOperationException is raised if the number has already been assigned.</exception>
        void IssueMembershipNumber(Member member, string number);
    }
}
